import { createRouter, createWebHashHistory } from "vue-router";
import { guard } from "./guard";

const router = createRouter({
    history: createWebHashHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: "/layout",
            redirect: "/",
            component: () => import("@/components/layout/layout.vue"),
            children: [
                {
                    path: "/",
                    component: () => import("@/pages/home/home.vue"),
                },
                {
                    path: "/css/border",
                    component: () => import("@/pages/css/border/border.vue"),
                },
                {
                    path: "/css/font",
                    component: () => import("@/pages/css/font/font.vue"),
                },
                {
                    path: "/css/charge",
                    component: () => import("@/pages/css/charge/charge.vue"),
                },
                {
                    path: "/css/fragment",
                    component: () => import("@/pages/css/fragment/fragment.vue"),
                },
                {
                    path: "/css/snow",
                    component: () => import("@/pages/css/snow/snow.vue"),
                },
                {
                    path: "/css/progress",
                    component: () => import("@/pages/css/progress/progress.vue"),
                },
                {
                    path: "/css/shape",
                    component: () => import("@/pages/css/shape/shape.vue"),
                },
                {
                    path: "/css/album",
                    component: () => import("@/pages/css/album/album.vue"),
                },
                {
                    path: "/css/cube",
                    component: () => import("@/pages/css/cube/cube.vue"),
                },
                {
                    path: "/css/dice",
                    component: () => import("@/pages/css/dice/dice.vue"),
                },
                {
                    path: "/javascript/scrape",
                    component: () => import("@/pages/javascript/scrape/scrape.vue"),
                },
                {
                    path: "/javascript/paint",
                    component: () => import("@/pages/javascript/paint/paint.vue"),
                },
                {
                    path: "/javascript/starry",
                    component: () => import("@/pages/javascript/starry/starry.vue"),
                },
                {
                    path: "/javascript/panorama",
                    component: () => import("@/pages/javascript/panorama/panorama.vue"),
                },
                {
                    path: "/javascript/earth",
                    component: () => import("@/pages/javascript/earth/earth.vue"),
                },
                {
                    path: "/javascript/video-call",
                    component: () => import("@/pages/javascript/video-call/video-call.vue"),
                    meta: {
                        needUser: true
                    }
                },
                {
                    path: "/javascript/upload",
                    component: () => import("@/pages/javascript/upload/upload.vue"),
                    meta: {
                        needUser: true
                    }
                },
                {
                    path: "/javascript/webcam",
                    component: () => import("@/pages/javascript/webcam/webcam.vue"),
                },
                {
                    path: "/game/monopoly",
                    component: () => import("@/pages/game/monopoly/monopoly.vue"),
                },
                {
                    path: "/game/luck_draw",
                    component: () => import("@/pages/game/luck_draw/luck_draw.vue"),
                },
                {
                    path: "/game/egg",
                    component: () => import("@/pages/game/egg/egg.vue"),
                },
                {
                    path: "/game/collect-star",
                    component: () => import("@/pages/game/collect-star/collect-star.vue"),
                },
                {
                    path: "/game/flappy-bird",
                    component: () => import("@/pages/game/flappy-bird/flappy-bird.vue"),
                },
                {
                    path: "/game/plane-war",
                    component: () => import("@/pages/game/plane-war/plane-war.vue"),
                },
                {
                    path: "/game/snake",
                    component: () => import("@/pages/game/snake/snake.vue"),
                },
                {
                    path: "/game/snake2",
                    component: () => import("@/pages/game/snake2/snake2.vue"),
                },
                {
                    path: "/game/snowmen-attack",
                    component: () => import("@/pages/game/snowmen-attack/snowmen-attack.vue"),
                },
                {
                    path: "/game/tetris",
                    component: () => import("@/pages/game/tetris/tetris.vue"),
                },
                {
                    path: "/ai",
                    component: () => import("@/pages/ai/ai.vue"),
                    meta: {
                        needUser: true
                    }
                },
            ],
        },
    ],
});

router.beforeEach(guard);

export default router;
